﻿using System;
using Socium.Domain.Persons;

namespace Socium.Domain.Tests.Testings {
	[Serializable]
	public class ClosedAnswer : Answer {
		public ClosedAnswer(Person person, Variant variant) : base(person) {
			Variant = variant;
		}

		public override string ToString() {
			return string.Format("Person = {0}", Person);
		}

		public Variant Variant { get; private set; }

		public override bool IsMatch(object o) {
			var variant = o as Variant;
			if (variant != null) {
				return Variant == variant;
			}

			var question = o as ClosedQuestion;
			if (question != null) {
				return question.Variants.Contains(Variant);
			}

			return false;
		}
	}
}
